﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using LibFriesland_Campina_CRM;

public partial class Samples_SimpleMapWithBubble : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //You must specify Google Map API Key for this component. You can obtain this key from http://code.google.com/apis/maps/signup.html
        //For samples to run properly, set GoogleAPIKey in Web.Config file.
        GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"]; 

        //Specify width and height for map. You can specify either in pixels or in percentage relative to it's container.
        GoogleMapForASPNet1.GoogleMapObject.Width = "800px"; // You can also specify percentage(e.g. 80%) here
        GoogleMapForASPNet1.GoogleMapObject.Height = "600px";

        //Specify initial Zoom level.
        GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 16;
        double latGps = 0;
        double longGps = 0;
        string infoHTML = "";
        string viewType = Request.QueryString["type"].ToString();

        //Specify Center Point for map. Map will be centered on this point.
        switch (viewType)
        { 
            case "viewTrackingPoint": latGps = Convert.ToDouble(Request.QueryString["latGps"].ToString());
                longGps = Convert.ToDouble(Request.QueryString["longGps"].ToString());
                infoHTML = String.Format("Kinh độ:{0} <br/> Vĩ độ: {1}", longGps, latGps);
                break;

            case "viewShopPoint": string shopCharID = Request.QueryString["shop"].ToString();
                BizShop shop = BizShop.getShopbyID(shopCharID);
                latGps = shop.latitude;
                longGps = shop.longitude;
                infoHTML = String.Format("{0} <br/> Kinh độ:{1} <br/> Vĩ độ: {2}", shop.name, shop.longitude, shop.latitude);
                break;
        }
        
        //string shopCharID = Request.QueryString["shop"].ToString();
        GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", latGps, longGps);

        //Add pushpins for map. 
        //This should be done with intialization of GooglePoint class. 
        //ID is to identify a pushpin. It must be unique for each pin. Type is string.
        //Other properties latitude and longitude.
        
        //Hien thi vi tri cham cong
        GooglePoint GP1 = new GooglePoint();
        GP1.ID = "1";
        GP1.Latitude = latGps;
        GP1.Longitude = longGps;
        GP1.InfoHTML = infoHTML;
        GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1);

        //GooglePoint GP2 = new GooglePoint();
        //GP3.ID = "2";
        //GP3.Latitude = 43.67689;
        //GP3.Longitude = -79.43270;
        //GP3.InfoHTML = "This is point 2";
        //GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP2);

        //GooglePoint GP3 = new GooglePoint();
        //GP3.ID = "3";
        //GP3.Latitude = 43.67689;
        //GP3.Longitude = -79.43270;
        //GP3.InfoHTML = "This is point 3";
        //GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP3);
    }
}
